package com.peng.my_blog.util;

import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.support.PropertiesLoaderUtils;

import java.io.IOException;
import java.util.Properties;

public class PropertiesUtil {
    private static Properties properties;

    static {
        try {
            properties = PropertiesLoaderUtils.loadProperties(new ClassPathResource("conf.properties"));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static String getProperty(String keyName){
        return properties.getProperty(keyName);


    }
    public static String getProperty(String confFileName,String keyName){
        try {
            Properties properties = PropertiesLoaderUtils.loadProperties(new ClassPathResource(confFileName));
        } catch (IOException e) {
            e.printStackTrace();
            return null;
        }
        return properties.getProperty(keyName);


    }
}
